package com.xupengdi.lab_3.controller;

import com.xupengdi.lab_3.model.RegionStats;
import com.xupengdi.lab_3.service.CheckDataService;
import com.xupengdi.lab_3.service.FetchDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.List;

@Controller
public class ShowDataController {

    @Autowired
    FetchDataService fetchDataService = new FetchDataService();
    @Autowired
    CheckDataService checkDataService = new CheckDataService();

    @RequestMapping("/showdata")
    @ResponseBody
    public List<RegionStats> showData() throws IOException {
        return fetchDataService.getData();
    }

    @RequestMapping("/country")
    @ResponseBody
    public List<RegionStats> showCountryData() throws IOException {
        return checkDataService.getData();
    }

}
